package com.aua.book.android.xml;

import java.util.List;

import android.text.Html;
import android.widget.TextView;

public class PageTurnHelper {

  public static int turnRight(AndroidBookActivity app, TextView currentPageText, TextView textView,
      List<String> pages, int CURRENT_PAGE, int LAST_PAGE) {
    CURRENT_PAGE++;
    if (CURRENT_PAGE > LAST_PAGE - 1)
      return LAST_PAGE - 1;
    String str = pages.get(CURRENT_PAGE);
    textView.setText(Html.fromHtml(str));
    int progress = (CURRENT_PAGE + 1) * 100 / LAST_PAGE;

    currentPageText.setText("Progress " + progress + "%");

    ProgressDisplay.displayProgress(app, progress);
    return CURRENT_PAGE;

  }

  public static int turnLeft(AndroidBookActivity app, TextView currentPageText, TextView textView,
      List<String> pages, int CURRENT_PAGE, int LAST_PAGE) {
    CURRENT_PAGE--;
    if (CURRENT_PAGE < 0)
      return 0;

    String str = pages.get(CURRENT_PAGE);
    textView.setText(Html.fromHtml(str));

    int progress = CURRENT_PAGE * 100 / LAST_PAGE;

    currentPageText.setText("Progress " + progress + "%");
    ProgressDisplay.displayProgress(app, progress);
    return CURRENT_PAGE;

  }
  
  public static int goToPage(AndroidBookActivity app,TextView currentPageText, TextView textView, List<String> pages, int CURRENT_PAGE,
      int LAST_PAGE) {
   

    String str =  pages.get(CURRENT_PAGE);
    textView.setText(Html.fromHtml(str));
    
    int progress = CURRENT_PAGE*100/LAST_PAGE;
    
    currentPageText.setText("Progress " + progress + "%");
   // app.displayProgress(progress);
    return CURRENT_PAGE;
  }

}
